package com.cicadalane.androlate;

/*
 * Copyright (C) 2011 cicada.software@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.program.Program;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Listener;



class StartPage extends AndrolateWizardPage implements Listener {
	protected StartPage(String pageName) {
		super(pageName);
		setTitle(pageName);
		setDescription("Localize Android projects with Google Translate\u2122");
	}

	private Label betaLabel = null;
	private Label welcomeLabel = null;
	private Label logoLabel = null;
	private ImageDescriptor logoImageDescriptor = null;
	private Link supportLink = null;

	@Override
	public void createControl(Composite parent) {
		Composite composite = new Composite(parent, SWT.NONE);

		GridLayout gl = new GridLayout();
		composite.setLayoutData(new GridData(GridData.FILL));
		gl.numColumns = 1;
		gl.makeColumnsEqualWidth = true;
		composite.setLayout(gl);

		logoImageDescriptor = Activator.getImageDescriptor("icons/androlate-logo.png");
		logoLabel = new Label(composite, SWT.IMAGE_PNG);
		logoLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.CENTER));
		((GridData) logoLabel.getLayoutData()).horizontalSpan = 1;
		logoLabel.setImage(logoImageDescriptor.createImage());
		
		betaLabel = new Label(composite, SWT.NONE);
		betaLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		((GridData) betaLabel.getLayoutData()).horizontalSpan = 1;
		betaLabel.setText("THIS IS BETA SOFTWARE!  Please backup your project before using.");
		betaLabel.setBackground(SwtUtils.convertAwtColorToSwtColor(composite, java.awt.Color.YELLOW));
		
		welcomeLabel = new Label(composite, SWT.NONE);
		welcomeLabel.setLayoutData(new GridData(GridData.FILL));
		((GridData) welcomeLabel.getLayoutData()).horizontalSpan = 1;
		welcomeLabel.setText("Use this wizard to translate your Android project's string resources with Google Translate\u2122");

		supportLink = new Link(composite, SWT.NONE);
		supportLink.setLayoutData(new GridData(GridData.FILL_BOTH));
		((GridData) supportLink.getLayoutData()).horizontalSpan = 1;
		supportLink.setText("send feedback to <a href=\"native\">support@cicadalane.com</a>.");
		supportLink.addListener (SWT.Selection, new Listener () {
			public void handleEvent(Event event) {
				Program.launch("mailto:support@cicadalane.com?subject=Androlate Feedback");
			}
		});

		setControl(composite);
	}



	@Override
	public void handleEvent(Event event) {
	}
}
